<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <title>dlaein.f</title>
 <meta name="generator" content="emacs 21.3.1; htmlfontify 0.20">
<style type="text/css"><!-- 
body { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default   { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default a { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.string   { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.string a { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.comment   { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.comment a { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
 --></style>

 </head>
  <body>

<pre>
      SUBROUTINE <a name="DLAEIN.1"></a><a href="dlaein.f.html#DLAEIN.1">DLAEIN</a>( RIGHTV, NOINIT, N, H, LDH, WR, WI, VR, VI, B,
     $                   LDB, WORK, EPS3, SMLNUM, BIGNUM, INFO )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  -- LAPACK auxiliary routine (version 3.1) --
</span><span class="comment">*</span><span class="comment">     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
</span><span class="comment">*</span><span class="comment">     November 2006
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. Scalar Arguments ..
</span>      LOGICAL            NOINIT, RIGHTV
      INTEGER            INFO, LDB, LDH, N
      DOUBLE PRECISION   BIGNUM, EPS3, SMLNUM, WI, WR
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Array Arguments ..
</span>      DOUBLE PRECISION   B( LDB, * ), H( LDH, * ), VI( * ), VR( * ),
     $                   WORK( * )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Purpose
</span><span class="comment">*</span><span class="comment">  =======
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  <a name="DLAEIN.21"></a><a href="dlaein.f.html#DLAEIN.1">DLAEIN</a> uses inverse iteration to find a right or left eigenvector
</span><span class="comment">*</span><span class="comment">  corresponding to the eigenvalue (WR,WI) of a real upper Hessenberg
</span><span class="comment">*</span><span class="comment">  matrix H.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Arguments
</span><span class="comment">*</span><span class="comment">  =========
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  RIGHTV   (input) LOGICAL
</span><span class="comment">*</span><span class="comment">          = .TRUE. : compute right eigenvector;
</span><span class="comment">*</span><span class="comment">          = .FALSE.: compute left eigenvector.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  NOINIT   (input) LOGICAL
</span><span class="comment">*</span><span class="comment">          = .TRUE. : no initial vector supplied in (VR,VI).
</span><span class="comment">*</span><span class="comment">          = .FALSE.: initial vector supplied in (VR,VI).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  N       (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The order of the matrix H.  N &gt;= 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  H       (input) DOUBLE PRECISION array, dimension (LDH,N)
</span><span class="comment">*</span><span class="comment">          The upper Hessenberg matrix H.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LDH     (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The leading dimension of the array H.  LDH &gt;= max(1,N).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  WR      (input) DOUBLE PRECISION
</span><span class="comment">*</span><span class="comment">  WI      (input) DOUBLE PRECISION
</span><span class="comment">*</span><span class="comment">          The real and imaginary parts of the eigenvalue of H whose
</span><span class="comment">*</span><span class="comment">          corresponding right or left eigenvector is to be computed.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  VR      (input/output) DOUBLE PRECISION array, dimension (N)
</span><span class="comment">*</span><span class="comment">  VI      (input/output) DOUBLE PRECISION array, dimension (N)
</span><span class="comment">*</span><span class="comment">          On entry, if NOINIT = .FALSE. and WI = 0.0, VR must contain
</span><span class="comment">*</span><span class="comment">          a real starting vector for inverse iteration using the real
</span><span class="comment">*</span><span class="comment">          eigenvalue WR; if NOINIT = .FALSE. and WI.ne.0.0, VR and VI
</span><span class="comment">*</span><span class="comment">          must contain the real and imaginary parts of a complex
</span><span class="comment">*</span><span class="comment">          starting vector for inverse iteration using the complex
</span><span class="comment">*</span><span class="comment">          eigenvalue (WR,WI); otherwise VR and VI need not be set.
</span><span class="comment">*</span><span class="comment">          On exit, if WI = 0.0 (real eigenvalue), VR contains the
</span><span class="comment">*</span><span class="comment">          computed real eigenvector; if WI.ne.0.0 (complex eigenvalue),
</span><span class="comment">*</span><span class="comment">          VR and VI contain the real and imaginary parts of the
</span><span class="comment">*</span><span class="comment">          computed complex eigenvector. The eigenvector is normalized
</span><span class="comment">*</span><span class="comment">          so that the component of largest magnitude has magnitude 1;
</span><span class="comment">*</span><span class="comment">          here the magnitude of a complex number (x,y) is taken to be
</span><span class="comment">*</span><span class="comment">          |x| + |y|.
</span><span class="comment">*</span><span class="comment">          VI is not referenced if WI = 0.0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  B       (workspace) DOUBLE PRECISION array, dimension (LDB,N)
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LDB     (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The leading dimension of the array B.  LDB &gt;= N+1.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  WORK   (workspace) DOUBLE PRECISION array, dimension (N)
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  EPS3    (input) DOUBLE PRECISION
</span><span class="comment">*</span><span class="comment">          A small machine-dependent value which is used to perturb
</span><span class="comment">*</span><span class="comment">          close eigenvalues, and to replace zero pivots.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  SMLNUM  (input) DOUBLE PRECISION
</span><span class="comment">*</span><span class="comment">          A machine-dependent value close to the underflow threshold.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  BIGNUM  (input) DOUBLE PRECISION
</span><span class="comment">*</span><span class="comment">          A machine-dependent value close to the overflow threshold.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  INFO    (output) INTEGER
</span><span class="comment">*</span><span class="comment">          = 0:  successful exit
</span><span class="comment">*</span><span class="comment">          = 1:  inverse iteration did not converge; VR is set to the
</span><span class="comment">*</span><span class="comment">                last iterate, and so is VI if WI.ne.0.0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  =====================================================================
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. Parameters ..
</span>      DOUBLE PRECISION   ZERO, ONE, TENTH
      PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0, TENTH = 1.0D-1 )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Local Scalars ..
</span>      CHARACTER          NORMIN, TRANS
      INTEGER            I, I1, I2, I3, IERR, ITS, J
      DOUBLE PRECISION   ABSBII, ABSBJJ, EI, EJ, GROWTO, NORM, NRMSML,
     $                   REC, ROOTN, SCALE, TEMP, VCRIT, VMAX, VNORM, W,
     $                   W1, X, XI, XR, Y
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Functions ..
</span>      INTEGER            IDAMAX
      DOUBLE PRECISION   DASUM, <a name="DLAPY2.104"></a><a href="dlapy2.f.html#DLAPY2.1">DLAPY2</a>, DNRM2
      EXTERNAL           IDAMAX, DASUM, <a name="DLAPY2.105"></a><a href="dlapy2.f.html#DLAPY2.1">DLAPY2</a>, DNRM2
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Subroutines ..
</span>      EXTERNAL           <a name="DLADIV.108"></a><a href="dladiv.f.html#DLADIV.1">DLADIV</a>, <a name="DLATRS.108"></a><a href="dlatrs.f.html#DLATRS.1">DLATRS</a>, DSCAL
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Intrinsic Functions ..
</span>      INTRINSIC          ABS, DBLE, MAX, SQRT
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Executable Statements ..
</span><span class="comment">*</span><span class="comment">
</span>      INFO = 0
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     GROWTO is the threshold used in the acceptance test for an
</span><span class="comment">*</span><span class="comment">     eigenvector.
</span><span class="comment">*</span><span class="comment">
</span>      ROOTN = SQRT( DBLE( N ) )
      GROWTO = TENTH / ROOTN
      NRMSML = MAX( ONE, EPS3*ROOTN )*SMLNUM
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Form B = H - (WR,WI)*I (except that the subdiagonal elements and
</span><span class="comment">*</span><span class="comment">     the imaginary parts of the diagonal elements are not stored).
</span><span class="comment">*</span><span class="comment">
</span>      DO 20 J = 1, N
         DO 10 I = 1, J - 1
            B( I, J ) = H( I, J )
   10    CONTINUE
         B( J, J ) = H( J, J ) - WR
   20 CONTINUE
<span class="comment">*</span><span class="comment">
</span>      IF( WI.EQ.ZERO ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Real eigenvalue.
</span><span class="comment">*</span><span class="comment">
</span>         IF( NOINIT ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Set initial vector.
</span><span class="comment">*</span><span class="comment">
</span>            DO 30 I = 1, N
               VR( I ) = EPS3
   30       CONTINUE
         ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Scale supplied initial vector.
</span><span class="comment">*</span><span class="comment">
</span>            VNORM = DNRM2( N, VR, 1 )
            CALL DSCAL( N, ( EPS3*ROOTN ) / MAX( VNORM, NRMSML ), VR,
     $                  1 )
         END IF
<span class="comment">*</span><span class="comment">
</span>         IF( RIGHTV ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           LU decomposition with partial pivoting of B, replacing zero
</span><span class="comment">*</span><span class="comment">           pivots by EPS3.
</span><span class="comment">*</span><span class="comment">
</span>            DO 60 I = 1, N - 1
               EI = H( I+1, I )
               IF( ABS( B( I, I ) ).LT.ABS( EI ) ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">                 Interchange rows and eliminate.
</span><span class="comment">*</span><span class="comment">
</span>                  X = B( I, I ) / EI
                  B( I, I ) = EI
                  DO 40 J = I + 1, N
                     TEMP = B( I+1, J )
                     B( I+1, J ) = B( I, J ) - X*TEMP
                     B( I, J ) = TEMP
   40             CONTINUE
               ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">                 Eliminate without interchange.
</span><span class="comment">*</span><span class="comment">
</span>                  IF( B( I, I ).EQ.ZERO )
     $               B( I, I ) = EPS3
                  X = EI / B( I, I )
                  IF( X.NE.ZERO ) THEN
                     DO 50 J = I + 1, N
                        B( I+1, J ) = B( I+1, J ) - X*B( I, J )
   50                CONTINUE
                  END IF
               END IF
   60       CONTINUE
            IF( B( N, N ).EQ.ZERO )
     $         B( N, N ) = EPS3
<span class="comment">*</span><span class="comment">
</span>            TRANS = <span class="string">'N'</span>
<span class="comment">*</span><span class="comment">
</span>         ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           UL decomposition with partial pivoting of B, replacing zero
</span><span class="comment">*</span><span class="comment">           pivots by EPS3.
</span><span class="comment">*</span><span class="comment">
</span>            DO 90 J = N, 2, -1
               EJ = H( J, J-1 )
               IF( ABS( B( J, J ) ).LT.ABS( EJ ) ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">                 Interchange columns and eliminate.
</span><span class="comment">*</span><span class="comment">
</span>                  X = B( J, J ) / EJ
                  B( J, J ) = EJ
                  DO 70 I = 1, J - 1
                     TEMP = B( I, J-1 )
                     B( I, J-1 ) = B( I, J ) - X*TEMP
                     B( I, J ) = TEMP
   70             CONTINUE
               ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">                 Eliminate without interchange.
</span><span class="comment">*</span><span class="comment">
</span>                  IF( B( J, J ).EQ.ZERO )
     $               B( J, J ) = EPS3
                  X = EJ / B( J, J )
                  IF( X.NE.ZERO ) THEN
                     DO 80 I = 1, J - 1
                        B( I, J-1 ) = B( I, J-1 ) - X*B( I, J )
   80                CONTINUE
                  END IF
               END IF
   90       CONTINUE
            IF( B( 1, 1 ).EQ.ZERO )
     $         B( 1, 1 ) = EPS3
<span class="comment">*</span><span class="comment">
</span>            TRANS = <span class="string">'T'</span>
<span class="comment">*</span><span class="comment">
</span>         END IF
<span class="comment">*</span><span class="comment">
</span>         NORMIN = <span class="string">'N'</span>
         DO 110 ITS = 1, N
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Solve U*x = scale*v for a right eigenvector
</span><span class="comment">*</span><span class="comment">             or U'*x = scale*v for a left eigenvector,
</span><span class="comment">*</span><span class="comment">           overwriting x on v.
</span><span class="comment">*</span><span class="comment">
</span>            CALL <a name="DLATRS.237"></a><a href="dlatrs.f.html#DLATRS.1">DLATRS</a>( <span class="string">'Upper'</span>, TRANS, <span class="string">'Nonunit'</span>, NORMIN, N, B, LDB,
     $                   VR, SCALE, WORK, IERR )
            NORMIN = <span class="string">'Y'</span>
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Test for sufficient growth in the norm of v.
</span><span class="comment">*</span><span class="comment">
</span>            VNORM = DASUM( N, VR, 1 )
            IF( VNORM.GE.GROWTO*SCALE )
     $         GO TO 120
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Choose new orthogonal starting vector and try again.
</span><span class="comment">*</span><span class="comment">
</span>            TEMP = EPS3 / ( ROOTN+ONE )
            VR( 1 ) = EPS3
            DO 100 I = 2, N
               VR( I ) = TEMP
  100       CONTINUE
            VR( N-ITS+1 ) = VR( N-ITS+1 ) - EPS3*ROOTN
  110    CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Failure to find eigenvector in N iterations.
</span><span class="comment">*</span><span class="comment">
</span>         INFO = 1
<span class="comment">*</span><span class="comment">
</span>  120    CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Normalize eigenvector.
</span><span class="comment">*</span><span class="comment">
</span>         I = IDAMAX( N, VR, 1 )
         CALL DSCAL( N, ONE / ABS( VR( I ) ), VR, 1 )
      ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Complex eigenvalue.
</span><span class="comment">*</span><span class="comment">
</span>         IF( NOINIT ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Set initial vector.
</span><span class="comment">*</span><span class="comment">
</span>            DO 130 I = 1, N
               VR( I ) = EPS3
               VI( I ) = ZERO
  130       CONTINUE
         ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Scale supplied initial vector.
</span><span class="comment">*</span><span class="comment">
</span>            NORM = <a name="DLAPY2.283"></a><a href="dlapy2.f.html#DLAPY2.1">DLAPY2</a>( DNRM2( N, VR, 1 ), DNRM2( N, VI, 1 ) )
            REC = ( EPS3*ROOTN ) / MAX( NORM, NRMSML )
            CALL DSCAL( N, REC, VR, 1 )
            CALL DSCAL( N, REC, VI, 1 )
         END IF
<span class="comment">*</span><span class="comment">
</span>         IF( RIGHTV ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           LU decomposition with partial pivoting of B, replacing zero
</span><span class="comment">*</span><span class="comment">           pivots by EPS3.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           The imaginary part of the (i,j)-th element of U is stored in
</span><span class="comment">*</span><span class="comment">           B(j+1,i).
</span><span class="comment">*</span><span class="comment">
</span>            B( 2, 1 ) = -WI
            DO 140 I = 2, N
               B( I+1, 1 ) = ZERO
  140       CONTINUE
<span class="comment">*</span><span class="comment">
</span>            DO 170 I = 1, N - 1
               ABSBII = <a name="DLAPY2.303"></a><a href="dlapy2.f.html#DLAPY2.1">DLAPY2</a>( B( I, I ), B( I+1, I ) )
               EI = H( I+1, I )
               IF( ABSBII.LT.ABS( EI ) ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">                 Interchange rows and eliminate.
</span><span class="comment">*</span><span class="comment">
</span>                  XR = B( I, I ) / EI
                  XI = B( I+1, I ) / EI
                  B( I, I ) = EI
                  B( I+1, I ) = ZERO
                  DO 150 J = I + 1, N
                     TEMP = B( I+1, J )
                     B( I+1, J ) = B( I, J ) - XR*TEMP
                     B( J+1, I+1 ) = B( J+1, I ) - XI*TEMP
                     B( I, J ) = TEMP
                     B( J+1, I ) = ZERO
  150             CONTINUE
                  B( I+2, I ) = -WI
                  B( I+1, I+1 ) = B( I+1, I+1 ) - XI*WI
                  B( I+2, I+1 ) = B( I+2, I+1 ) + XR*WI
               ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">                 Eliminate without interchanging rows.
</span><span class="comment">*</span><span class="comment">
</span>                  IF( ABSBII.EQ.ZERO ) THEN
                     B( I, I ) = EPS3
                     B( I+1, I ) = ZERO
                     ABSBII = EPS3
                  END IF
                  EI = ( EI / ABSBII ) / ABSBII
                  XR = B( I, I )*EI
                  XI = -B( I+1, I )*EI
                  DO 160 J = I + 1, N
                     B( I+1, J ) = B( I+1, J ) - XR*B( I, J ) +
     $                             XI*B( J+1, I )
                     B( J+1, I+1 ) = -XR*B( J+1, I ) - XI*B( I, J )
  160             CONTINUE
                  B( I+2, I+1 ) = B( I+2, I+1 ) - WI
               END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              Compute 1-norm of offdiagonal elements of i-th row.
</span><span class="comment">*</span><span class="comment">
</span>               WORK( I ) = DASUM( N-I, B( I, I+1 ), LDB ) +
     $                     DASUM( N-I, B( I+2, I ), 1 )
  170       CONTINUE
            IF( B( N, N ).EQ.ZERO .AND. B( N+1, N ).EQ.ZERO )
     $         B( N, N ) = EPS3
            WORK( N ) = ZERO
<span class="comment">*</span><span class="comment">
</span>            I1 = N
            I2 = 1
            I3 = -1
         ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           UL decomposition with partial pivoting of conjg(B),
</span><span class="comment">*</span><span class="comment">           replacing zero pivots by EPS3.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           The imaginary part of the (i,j)-th element of U is stored in
</span><span class="comment">*</span><span class="comment">           B(j+1,i).
</span><span class="comment">*</span><span class="comment">
</span>            B( N+1, N ) = WI
            DO 180 J = 1, N - 1
               B( N+1, J ) = ZERO
  180       CONTINUE
<span class="comment">*</span><span class="comment">
</span>            DO 210 J = N, 2, -1
               EJ = H( J, J-1 )
               ABSBJJ = <a name="DLAPY2.370"></a><a href="dlapy2.f.html#DLAPY2.1">DLAPY2</a>( B( J, J ), B( J+1, J ) )
               IF( ABSBJJ.LT.ABS( EJ ) ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">                 Interchange columns and eliminate
</span><span class="comment">*</span><span class="comment">
</span>                  XR = B( J, J ) / EJ
                  XI = B( J+1, J ) / EJ
                  B( J, J ) = EJ
                  B( J+1, J ) = ZERO
                  DO 190 I = 1, J - 1
                     TEMP = B( I, J-1 )
                     B( I, J-1 ) = B( I, J ) - XR*TEMP
                     B( J, I ) = B( J+1, I ) - XI*TEMP
                     B( I, J ) = TEMP
                     B( J+1, I ) = ZERO
  190             CONTINUE
                  B( J+1, J-1 ) = WI
                  B( J-1, J-1 ) = B( J-1, J-1 ) + XI*WI
                  B( J, J-1 ) = B( J, J-1 ) - XR*WI
               ELSE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">                 Eliminate without interchange.
</span><span class="comment">*</span><span class="comment">
</span>                  IF( ABSBJJ.EQ.ZERO ) THEN
                     B( J, J ) = EPS3
                     B( J+1, J ) = ZERO
                     ABSBJJ = EPS3
                  END IF
                  EJ = ( EJ / ABSBJJ ) / ABSBJJ
                  XR = B( J, J )*EJ
                  XI = -B( J+1, J )*EJ
                  DO 200 I = 1, J - 1
                     B( I, J-1 ) = B( I, J-1 ) - XR*B( I, J ) +
     $                             XI*B( J+1, I )
                     B( J, I ) = -XR*B( J+1, I ) - XI*B( I, J )
  200             CONTINUE
                  B( J, J-1 ) = B( J, J-1 ) + WI
               END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">              Compute 1-norm of offdiagonal elements of j-th column.
</span><span class="comment">*</span><span class="comment">
</span>               WORK( J ) = DASUM( J-1, B( 1, J ), 1 ) +
     $                     DASUM( J-1, B( J+1, 1 ), LDB )
  210       CONTINUE
            IF( B( 1, 1 ).EQ.ZERO .AND. B( 2, 1 ).EQ.ZERO )
     $         B( 1, 1 ) = EPS3
            WORK( 1 ) = ZERO
<span class="comment">*</span><span class="comment">
</span>            I1 = 1
            I2 = N
            I3 = 1
         END IF
<span class="comment">*</span><span class="comment">
</span>         DO 270 ITS = 1, N
            SCALE = ONE
            VMAX = ONE
            VCRIT = BIGNUM
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Solve U*(xr,xi) = scale*(vr,vi) for a right eigenvector,
</span><span class="comment">*</span><span class="comment">             or U'*(xr,xi) = scale*(vr,vi) for a left eigenvector,
</span><span class="comment">*</span><span class="comment">           overwriting (xr,xi) on (vr,vi).
</span><span class="comment">*</span><span class="comment">
</span>            DO 250 I = I1, I2, I3
<span class="comment">*</span><span class="comment">
</span>               IF( WORK( I ).GT.VCRIT ) THEN
                  REC = ONE / VMAX
                  CALL DSCAL( N, REC, VR, 1 )
                  CALL DSCAL( N, REC, VI, 1 )
                  SCALE = SCALE*REC
                  VMAX = ONE
                  VCRIT = BIGNUM
               END IF
<span class="comment">*</span><span class="comment">
</span>               XR = VR( I )
               XI = VI( I )
               IF( RIGHTV ) THEN
                  DO 220 J = I + 1, N
                     XR = XR - B( I, J )*VR( J ) + B( J+1, I )*VI( J )
                     XI = XI - B( I, J )*VI( J ) - B( J+1, I )*VR( J )
  220             CONTINUE
               ELSE
                  DO 230 J = 1, I - 1
                     XR = XR - B( J, I )*VR( J ) + B( I+1, J )*VI( J )
                     XI = XI - B( J, I )*VI( J ) - B( I+1, J )*VR( J )
  230             CONTINUE
               END IF
<span class="comment">*</span><span class="comment">
</span>               W = ABS( B( I, I ) ) + ABS( B( I+1, I ) )
               IF( W.GT.SMLNUM ) THEN
                  IF( W.LT.ONE ) THEN
                     W1 = ABS( XR ) + ABS( XI )
                     IF( W1.GT.W*BIGNUM ) THEN
                        REC = ONE / W1
                        CALL DSCAL( N, REC, VR, 1 )
                        CALL DSCAL( N, REC, VI, 1 )
                        XR = VR( I )
                        XI = VI( I )
                        SCALE = SCALE*REC
                        VMAX = VMAX*REC
                     END IF
                  END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">                 Divide by diagonal element of B.
</span><span class="comment">*</span><span class="comment">
</span>                  CALL <a name="DLADIV.474"></a><a href="dladiv.f.html#DLADIV.1">DLADIV</a>( XR, XI, B( I, I ), B( I+1, I ), VR( I ),
     $                         VI( I ) )
                  VMAX = MAX( ABS( VR( I ) )+ABS( VI( I ) ), VMAX )
                  VCRIT = BIGNUM / VMAX
               ELSE
                  DO 240 J = 1, N
                     VR( J ) = ZERO
                     VI( J ) = ZERO
  240             CONTINUE
                  VR( I ) = ONE
                  VI( I ) = ONE
                  SCALE = ZERO
                  VMAX = ONE
                  VCRIT = BIGNUM
               END IF
  250       CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Test for sufficient growth in the norm of (VR,VI).
</span><span class="comment">*</span><span class="comment">
</span>            VNORM = DASUM( N, VR, 1 ) + DASUM( N, VI, 1 )
            IF( VNORM.GE.GROWTO*SCALE )
     $         GO TO 280
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           Choose a new orthogonal starting vector and try again.
</span><span class="comment">*</span><span class="comment">
</span>            Y = EPS3 / ( ROOTN+ONE )
            VR( 1 ) = EPS3
            VI( 1 ) = ZERO
<span class="comment">*</span><span class="comment">
</span>            DO 260 I = 2, N
               VR( I ) = Y
               VI( I ) = ZERO
  260       CONTINUE
            VR( N-ITS+1 ) = VR( N-ITS+1 ) - EPS3*ROOTN
  270    CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Failure to find eigenvector in N iterations
</span><span class="comment">*</span><span class="comment">
</span>         INFO = 1
<span class="comment">*</span><span class="comment">
</span>  280    CONTINUE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Normalize eigenvector.
</span><span class="comment">*</span><span class="comment">
</span>         VNORM = ZERO
         DO 290 I = 1, N
            VNORM = MAX( VNORM, ABS( VR( I ) )+ABS( VI( I ) ) )
  290    CONTINUE
         CALL DSCAL( N, ONE / VNORM, VR, 1 )
         CALL DSCAL( N, ONE / VNORM, VI, 1 )
<span class="comment">*</span><span class="comment">
</span>      END IF
<span class="comment">*</span><span class="comment">
</span>      RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     End of <a name="DLAEIN.529"></a><a href="dlaein.f.html#DLAEIN.1">DLAEIN</a>
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>
